package cn.itcast.controller;


import cn.itcast.constant.MessageConstant;

import cn.itcast.entity.Result;
import cn.itcast.pojo.Role;
import cn.itcast.service.RoleService;
import com.alibaba.dubbo.config.annotation.Reference;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/role")
@CrossOrigin
@Slf4j
public class RoleController {
    
    @Reference
    private RoleService roleService;

    @GetMapping("/all")
    public Result findAllRole() {
        try {
            List<Role> roles = roleService.findAll();
            log.info("------RoleController------findAllRole------所有角色信息roles------"+roles);
            return new Result(true, MessageConstant.QUERY_CHECKITEM_SUCCESS, roles);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, MessageConstant.QUERY_CHECKITEM_FAIL);
        }
    }

}
